<?php

use App\Http\Controllers\RegionController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\file\UploadController;
use App\Http\Controllers\user\LoginController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    Route::post('/user/logout', [LoginController::class, 'logout']);
//    return $request->user();
//});

Route::post('/upload/image', [UploadController::class, 'image']);

Route::group(
    [
        'prefix' => '/portal',
        'namespace' => 'App\Http\Controllers\portal',
    ],
    function ($api) {
        $api->get('index', 'IndexController@index');

        $api->get('config', 'IndexController@config');

        $api->get('list', 'ArticleController@list');

        $api->get('info', 'ArticleController@info');

        $api->get('miniList', 'ArticleController@miniList');

        $api->get('fundraisingList', 'ManagerController@list');

        $api->get('fundraisingCount', 'ManagerController@count');

        $api->get('fundraisingtypeList', 'ManagerController@typeList');
    }
);


Route::group(
    [
        'prefix' => '/user',
        'namespace' => 'App\Http\Controllers\user',
    ],
    function ($api) {
        $api->get('loginOrRegister', 'LoginController@loginOrRegister');

        $api->get('phoneLogin', 'LoginController@phoneLogin');

        $api->post('upload', 'LoginController@upload');

        // 需要鉴权的接口
        Route::middleware('auth:sanctum')->group(function () {
            Route::post('logout', [LoginController::class, 'logout']);
        });
    }
);

Route::group(
    [
        'prefix' => '/family',
        'namespace' => 'App\Http\Controllers\family',
    ],
    function ($api) {
        $api->post('createFund', 'FundController@createFund');

        $api->get('fundDetails', 'FundController@fundDetails');

        $api->post('updateFundDescription', 'FundController@updateFundDescription');
    }
);

